// components/workerOrderCard.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    card: {
      type: Object,
      default () {
        return {imgs:[],address:{},user:{},date:{}};
      }
    },
    //myOrder=自己订单，done=自己订单没有操作按钮，为空则是抢单模式
    type: {
      type: String,
      default:''
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    no_cate:('/static/images/empty/home_cate.png'),
  },
  lifetimes:{
    attached(){
      this.setData({
        'card.show_tel_status':[3,4].indexOf(this.data.card.status)>=0
      })
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    acBtn(e){
      let type=e.currentTarget.dataset.val;
      this.triggerEvent('btnclick', {type:type,data:this.data.card});
    },
    more(){
      this.triggerEvent('btnclick',{type:'more',data:this.data.card});
    },
    done(){
      wx.navigateTo({
        url:"/pages/workerCode/done?sn="+this.data.card.sn
      })
    },
    openMap(s){
      console.log(s);
      let item = s.currentTarget.dataset.val;
      wx.openLocation({
        latitude: item.latitude,
        longitude: item.longitude,
        name:item.title,
        address:item.detail,
        success: function () {
          console.log('success');
        }
      });
    },
    callPhone(e){
      let s = e.currentTarget.dataset.val;
      wx.makePhoneCall({
        phoneNumber: s
      });
    }
  }
})